package com.jchy.graph;



public class Edge 
{
	private long id;
	
	private Vertex from;
	private Vertex to;
	
	public Edge()
	{
		from = null;
		to = null;
	}
	
	public Edge(Vertex inFrom, Vertex inTo)
	{
		from = inFrom;
		to = inTo;
	}
	
	public Vertex getFrom()
	{
		return from;
	}
	
	public Vertex getTo()
	{
		return to;
	}
	
	public boolean equals(Edge inEdge)
	{
		return (to.equals(inEdge.getTo())) && (from.equals(inEdge.getFrom()));	
	}
	
	public boolean equals(Object inEdge)
	{
		return (to.equals(((Edge)inEdge).getTo())) && (from.equals(((Edge)inEdge).getFrom()));	
	}
	
	public int hashCode()
	{
		int result;
		
		result = (int)(to.getId() & from.getId());
		
		return result;
	}
	
	public String toString()
	{
		String result = "From: " + String.valueOf(from) + " To: " + String.valueOf(to);
		return result;
	}

	public void setId(long inId)
	{
		id = inId;
	}
	
	public long getId()
	{
		return id;
	}
}
